<?

require_once  $_SERVER['DOCUMENT_ROOT']."/../_lib/base/common.php";
require_once SITE_ROOT_PATH."/_lib/classes/class.user_auth.php";

// FUNCTION // Display home ================================================
function display_home($errors=''){
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="styles/cms.css" rel="stylesheet" type="text/css" />
<style>
* {
	margin: 0px;
	padding: 0px;
	font-family: Verdana, Arial, Helvetica, sans-serif;
	color: #000000;
	font-size: 11px;
}

body, html {
	background: #fff;
	text-align: center;
}

img {
	border: 0;
}


table {
	border-collapse:collapse;
}

td, th {
	vertical-align: top;
}

a {
	color: #831E19;
	text-decoration: underline;
}

a:hover {
	color: #000;
	text-decoration: none;
}

h1, h2, h3, h4 {
	margin-bottom: 20px;
}

p, ul, ol, dl, fieldset {
	border: 0px;
	margin-bottom: 20px;
	font-size: 11px;
	color: #000000;
}

label, li, input, textarea, option, select, th, td {
	font-size: 11px;
	color: #000000;
}

option {
	padding-right: 5px;
}

h1, h2, h3, p, li, th, td, label {
	line-height: 140%;
}


html>body li {
	margin-left: 1em;  
}

ul, ol {
	margin-left: 15px;
	padding-left: 15px;
}

h1 {
	font-size: 21px;
	font-weight: bold;
	text-transform: capitalize;
	text-align: center;
}



fieldset {
	border: 0px;

}

div#wrapper {
	background-color: #F5F6F8;
	padding: 10px;
	width: 260px;
	margin: 10px auto;
	text-align: left;
}


/* form errors ========= */

dl.errors {
	width: 240px;
	padding: 10px;
	background-color:#FFFFFF;
}

dl.errors dt {
	font-weight: bold;
}

dl.errors dd {
	color: red;
	margin-bottom: 3px;
}


table.libra tr th, table.libra tr td {
	padding-bottom: 3px;
}

</style>


</head>

<body>

<div id="wrapper">






<form name="form" method="post" action="<?= $_SERVER['PHP_SELF'] ?>" style="display:block;margin: 0px 20px 10px 20px">

<input type="hidden" name="action" value="validate" />

    <table class="libra">
		<tr>
			<td width="90"><label>Password:</label></td>
			<td><input style="width: 80px;vertical-align:bottom;float:left" name="pass" type="password" size="12" /></td>
		</tr>
		<tr>
			<td></td>
			<td><input type="submit" name="Submit" value="Submit" /></td>
		</tr>
    </table>
  </form>



</div>
</body>
</hmtl>
<?
}
// END FUNCTION ================================================================

switch(@$_POST['action']) {
	case "home"; default;
		display_home();
	break;
	case "validate";
		if($_POST['pass'] !== "lat33nt3r"){
			display_home('Incorrect login details');
		}else{
	$user_auth = new user_auth();
	$user_auth->start_timer();
			header("Location: home.php"); 
		}
	break;
	case "logout":
		session_start();
		session_destroy();
		display_home();
	break;
}

?>